#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 2e7 + 10;

int z[N],p[N];
char a[N],b[N];

void Zfunc(char *s) {
	int ls = strlen(s + 1); z[1] = ls; 
	for(int i = 2,l = 0,r = 0;i <= ls;i++) {
		if(i <= r) z[i] = min(z[i - l + 1],r - i + 1);
		while(z[i] + i <= ls && s[z[i] + i] == s[z[i] + 1]) z[i]++;
		if(i + z[i] - 1 > r) r = i + z[i] - 1,l = i;
	}
}

void exKMP(char *a,char *b) {
	Zfunc(a); int ls = strlen(b + 1);
	for(int i = 1,l = 0,r = 0;i <= ls;i++) {
		if(i <= r) p[i] = min(z[i - l + 1],r - i + 1);
		while(p[i] + i <= ls && b[p[i] + i] == a[p[i] + 1]) p[i]++;
		if(i + p[i] - 1 > r) r = i + p[i] - 1,l = i;
	}
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	scanf("%s",a + 1); scanf("%s",b + 1); exKMP(b,a); ll ans = 0;
	for(int i = 1,l = strlen(b + 1);i <= l;i++) ans ^= (ll) (z[i] + 1) * i;
	printf("%lld\n",ans); ans = 0;
	for(int i = 1,l = strlen(a + 1);i <= l;i++) ans ^= (ll) (p[i] + 1) * i;
	printf("%lld\n",ans);
	return 0;
}
